﻿<!--#include file="base.asp"-->
<%
''' SDCMS 回收站
''' ==================================================================
''' 版权所有 http://www.sdcms.cn
''' ------------------------------------------------------------------
''' 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
''' 未经授权不允许对程序代码以任何形式任何目的的再发布。
''' ==================================================================
''' 编写: IT平民
''' 修改：IT平民 in 2014.07

	sub deldb()
		dim id:id=sdcms.enhtml(sdcms.fget("id",0))
		dim data
		data=sdcms.db.dbload(1,"id,(select tablename from view_category where cateid=sd_content.classid) as tablename,tags,classid,isurl,url","sd_content","id="&id&" and islock=-3","")
		if ubound(data)>=0 then
			if webmode=3 then
				dim fileurl:fileurl=sdcms.geturl(data(0,0),data(3,0),data(4,0),data(5,0))
				sdcms.delfile fileurl
			end if
			sdcms.db.dbdel data(1,0),"cid="&id&""
			deal_del_file id,1
			deal_tags data(2,0),""
			sdcms.db.dbdel "sd_expand_mood","contentid="&id&""
			sdcms.db.dbdel "sd_expand_comment","contentid="&id&""
			sdcms.db.dbdel "sd_user_favorite","contentid="&id&""
			sdcms.db.dbdel "sd_content","id="&id&" and islock=-3"
		end if
		sdcms.echo "1"
	end sub
	
	sub pass()
		dim id:id=sdcms.enhtml(sdcms.fget("id",0))
		sdcms.db.dbupdate "sd_content","id="&id&" and islock=-3",array(array("islock",1,0,0))
		sdcms.echo "1"
	end sub
	
	sub recoverysome()
		dim id:id=sdcms.enhtml(sdcms.fget("id",0))
		dim idarr:idarr=split(id,",")
		dim data
		if ubound(idarr)<0 then
			sdcms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					sdcms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				end if
			next
			sdcms.db.dbupdate "sd_content","id in("&id&") and islock=-3",array(array("islock",1,0,0))
			sdcms.echo "1"
		end if
	end sub
	
	sub delsome()
		dim id:id=sdcms.enhtml(sdcms.fget("id",0))
		dim idarr:idarr=split(id,",")
		dim data
		if ubound(idarr)<0 then
			sdcms.echo "0&#33267;&#23569;&#36873;&#25321;&#19968;&#26465;&#20449;&#24687;"
		else
			dim i
			for i=0 to ubound(idarr)
				if not isnumeric(idarr(i)) then
					sdcms.echo "0&#21442;&#25968;&#65306;"&id(i)&"&#19981;&#27491;&#30830;&#65292;&#35831;&#30830;&#35748;&#21518;&#20877;&#25805;&#20316;"
					exit sub
				else
					data=sdcms.db.dbload(1,"id,(select tablename from view_category where cateid=sd_content.classid) as tablename,tags,classid,isurl,url","sd_content","id="&idarr(i)&" and islock=-3","")
					if ubound(data)>=0 then
						if webmode=3 then
							dim fileurl:fileurl=sdcms.geturl(data(0,0),data(3,0),data(4,0),data(5,0))
							sdcms.delfile fileurl
						end if
						deal_del_file idarr(i),1
						sdcms.db.dbdel data(1,0),"cid="&idarr(i)&""
						deal_tags data(2,0),""
						sdcms.db.dbdel "sd_expand_mood","contentid="&idarr(i)&""
						sdcms.db.dbdel "sd_expand_comment","contentid="&idarr(i)&""
						sdcms.db.dbdel "sd_user_favorite","contentid="&idarr(i)&""
						sdcms.db.dbdel "sd_content","id="&idarr(i)&" and islock=-3"
					end if
				end if
			next
			sdcms.echo "1"
		end if
	end sub
	
	sub recovery()
		sdcms.db.dbupdate "sd_content","islock=-3",array(array("islock",1,0,0))
		sdcms.echo "1"
	end sub
	
	sub clearall()
		dim data,i
		data=sdcms.db.dbload("","id,(select tablename from view_category where cateid=sd_content.classid) as tablename,tags,classid,isurl,url","sd_content","islock=-3","")
		if ubound(data)>=0 then
			for i=0 to ubound(data,2)
				if webmode=3 then
					dim fileurl:fileurl=sdcms.geturl(data(0,i),data(3,i),data(4,i),data(5,i))
					sdcms.delfile fileurl
				end if
				sdcms.db.dbdel data(1,0),"cid="&data(0,i)&""
				deal_del_file data(0,i),1
				deal_tags data(2,i),""
				sdcms.db.dbdel "sd_expand_mood","contentid="&data(0,i)&""
				sdcms.db.dbdel "sd_expand_comment","contentid="&data(0,i)&""
				sdcms.db.dbdel "sd_user_favorite","contentid="&data(0,i)&""
				sdcms.db.dbdel "sd_content","islock=-3 and id="&data(0,i)&""
			next
		end if
		sdcms.echo "1"
	end sub
	
	islogin
	checkpagelever 21
	dim act:act=lcase(sdcms.fget("act",0))
	dim keyword:keyword=sdcms.enhtml(sdcms.fget("keyword",1))
	select case act
		case "del":deldb
		case "recoverysome":recoverysome
		case "delsome":delsome
		case "pass":pass
		case "recovery":recovery
		case "clearall":clearall
		case else
			dim orderby,wherekey
			if sdcms.strlen(keyword)>0 then
				if datatype then
					wherekey=" and instr(lcase(title),lcase('"&keyword&"'))>0 "
				else
					wherekey=" and title like '%"&keyword&"%'"
				end if
			end if
			load theme_contentrecycle
	end select
	sdcms.db.dbclose
%>